package cn.edu.suse.epilepsy.service.impl;

import cn.edu.suse.epilepsy.entity.pojo.CaseStd;
import cn.edu.suse.epilepsy.mapper.CaseStdMapper;
import cn.edu.suse.epilepsy.service.CaseStdService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CaseStdServiceImpl extends ServiceImpl<CaseStdMapper, CaseStd> implements CaseStdService {

    @Autowired
    private CaseStdMapper caseStdMapper;

    @Override
    public IPage<CaseStd> getCaseStds(Page<CaseStd> page, CaseStd caseStd) {
        QueryWrapper<CaseStd> queryWrapper = new QueryWrapper<>();

        // Add conditions based on the caseStd fields if needed
        if (caseStd.getCaseStdTopic() != null) {
            queryWrapper.like("case_std_topic", caseStd.getCaseStdTopic());
        }
        if (caseStd.getCaseStdCompere() != null) {
            queryWrapper.like("case_std_compere", caseStd.getCaseStdCompere());
        }
        if (caseStd.getCaseStdState() != null) {
            queryWrapper.eq("case_std_state", caseStd.getCaseStdState());
        }

        return caseStdMapper.selectPage(page, queryWrapper);
    }

}
